Digital multimedia capabilities can be incorporated into a wide range of devices, including digital televisions, digital direct broadcast systems, wireless communication devices, wireless broadcast systems, personal digital assistants (“PDAs”), laptop or desktop computers, digital cameras, digital recording devices, video gaming devices, video game consoles, cellular or satellite radio telephones, and the like. Digital multimedia devices may implement video coding techniques, such as techniques defined by the MPEG-2, MPEG-4, or ITU H.264/MPEG-4, Part 10, Advanced Video Coding (“AVC”) standards, to transmit and receive digital video data more efficiently. Video coding techniques may perform video compression via spatial and temporal prediction to reduce or remove redundancy inherent in video sequences.
In order to perform video compression via temporal prediction, a video encoder may use a motion compensation process. In a motion compensation process, a video encoder divides a current video frame into a set of macroblocks. Then, for each macroblock of the current video frame, the video encoder attempts to identify one or more macroblocks in one or more reference frames that contain approximately the same data as the macroblock in the current video frame. If the video encoder successfully identifies such a macroblock in the reference frame, the video encoder may generate a motion vector that indicates a displacement between the identified macroblock in the reference frame and the macroblock in the current frame. If the video encoder does not successfully identify such a macroblock in the reference frame, the video encoder may generate a motion vector that indicates no displacement. Next, the video encoder may generate a predictive frame by “moving” the identified macroblocks from positions in the reference frame to positions indicated by the motion vectors. After generating the predictive frame, the video encoder may generate a residual frame by subtracting, on a macroblock-by-macroblock basis, the predictive frame from the current frame to indicate residual differences between the corresponding blocks. The video encoder may then encode the residual frame along with its associated motion vectors. Next, the video encoder may output the encoded residual frame and the associated motion vectors for use by a decoder.
To decode a video frame that has been encoded using a motion compensation process, a video decoder may retrieve a reference frame indicated by the motion vectors. The video decoder may then “move” macroblocks of the reference frame indicated by the motion vectors to positions indicated by the motion vectors. As a result of moving the macroblocks of the reference frame, the video decoder generates a predictive frame. The video decoder may then generate a reconstructed video frame by adding the predictive frame to a decoded version of the received residual frame.